package com.test.webflux.dao;

import com.test.webflux.entity.Product;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;
import reactor.core.publisher.Mono;

import java.util.Objects;

/**
 * TODO
 *
 * @Description
 * @Author lingmin
 * @Date 2025/4/14 19:16
 **/
@Repository
public class ProductDao {


    /**
     * 查询产品
     * @param id
     * @return
     */
    public Mono<Product> getProductById(String id) {
        if (Objects.isNull(id) || "".equals(id) || "0".equals(id)) {
            return Mono.empty();
        }
        if ("-1".equals(id)) {
            throw new RuntimeException("id不合法");
        }
        Product product = new Product();
        product.setId(id);
        product.setProductNo("productNo-" + id);
        product.setName("product-" + id);
        return Mono.just(product);
    }
}
